package com.wtwd.campus.receiver;

import com.wtwd.campus.entity.MqGeneralSwitchResult;
import com.wtwd.campus.service.IRMFeignClientService;
import com.wtwd.campus.service.InjectFeignService;
import org.springframework.beans.factory.annotation.Autowired;

public class SetNoDisturbControllerReceiver implements Receiver {
    @Autowired
    private IRMFeignClientService irmFeignClientService;
    @Override
    public String parseMessage(String data) {
        //        String str = data.substring(0, data.length() - 1); //将指令末尾的#截取掉
        //分割字符串获取指令信息
        String[] split = data.split(",");
        String imei=split[1];
        String messageType = split[2];
        String type = split[3];
        String commandNumber=split[4];
        String flag=split[5];//0:两者都不用；1使用课表时间控制设备免打扰功能开关；2使用考勤标记控制设备免打扰功能开关；其他值=0；
        String deviceStatus=split[6];//设备状态
        MqGeneralSwitchResult mqGeneralSwitchResult = new MqGeneralSwitchResult();
        mqGeneralSwitchResult.setImei(imei);
        mqGeneralSwitchResult.setDeviceTime(commandNumber);
        mqGeneralSwitchResult.setCommandNumber(commandNumber);
        mqGeneralSwitchResult.setResult(Integer.parseInt(flag));
        mqGeneralSwitchResult.setDeviceStatus(deviceStatus);
        InjectFeignService.getIrmFeignClientService().callFunResponse(mqGeneralSwitchResult);
        return imei;
    }
}
